home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / Extension Shell 1.3 / Sample Extensions / MacCough ƒ / TimeTask.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-19  |  2.9 KB  |  113 lines  |  [TEXT/R*ch]

  1. /*    NAME:
  2.         TimeTask.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.                 
  7.     DESCRIPTION:
  8.         This file contains a CODE resource to be installed as a Time Manager task.
  9.  
  10.     NOTES:
  11.         •    We retrieve the handle to sound to play from the address table, and play it.
  12.  
  13.     ___________________________________________________________________________
  14.  
  15.     VERSION HISTORY:
  16.         (Mar 1994, dg)
  17.             •    First publicly distributed version.
  18.  
  19.  
  20.     ___________________________________________________________________________
  21. */
  22. //=============================================================================
  23. //        Include files                                                                     
  24. //-----------------------------------------------------------------------------
  25. #include <GestaltEqu.h>
  26. #include <Sound.h>
  27. #include "StandaloneCode.h"
  28. #include "MCAddrsTable.h"
  29. #include "ESConstants.h"
  30. #include "CodeConstants.h"
  31.  
  32.  
  33.  
  34.  
  35.  
  36. //=============================================================================
  37. //        Global Variables                                                                 
  38. //-----------------------------------------------------------------------------
  39. TMTask        *gOurTask;
  40. NMRec        gTheNMRec;
  41. Boolean        gAlreadyRan=false;
  42.  
  43.  
  44.  
  45.  
  46.  
  47. //=============================================================================
  48. //        Private function prototypes                             
  49. //-----------------------------------------------------------------------------
  50. pascal    void main(void);
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. //=============================================================================
  62. //        main : Entry point to our code resource.                                                                 
  63. //-----------------------------------------------------------------------------
  64. //        Note :    We get hold of the handle to the sound from our address table,
  65. //                and play it.
  66. //-----------------------------------------------------------------------------
  67. pascal void main(void)
  68. {    MCAddressTable    *theAddressTable;
  69.     OSErr            theErr;
  70.  
  71.  
  72.  
  73.  
  74.     // Get access to our globals, and save off A4
  75.     PatchGetGlobals();
  76.  
  77.     
  78.     
  79.     // If we've not already been called, call the Gestalt selector to get
  80.     // the address of our task record, and a handle to the sound to play.
  81.     if (!gAlreadyRan)
  82.         {
  83.         // Call gestalt and get the address of our task
  84.         Gestalt(kMacCoughAddressTable, &theAddressTable);        
  85.         gOurTask        = (ProcPtr) ((long) theAddressTable->theTable[kTimeTask]);
  86.         
  87.         
  88.         // Make up a Notification Manager request
  89.         gTheNMRec.qType        = nmType;                        // NM request type
  90.         gTheNMRec.nmMark    = 0;                            // No mark in the menu
  91.         gTheNMRec.nmIcon    = nil;                            // No icon in the menu
  92.         gTheNMRec.nmSound    = theAddressTable->theSound;    // Play this sound
  93.         gTheNMRec.nmStr        = nil;                            // Don't show a dialog
  94.         gTheNMRec.nmResp    = (ProcPtr) -1;                    // Remove the note afterwards
  95.         
  96.         
  97.         // This code doesn't need to be executed again
  98.         gAlreadyRan = true;
  99.         }
  100.     
  101.  
  102.     
  103.     // Install the Notification Manager request (which plays
  104.     // the sound) and requeue ourselves for 10 seconds from now.
  105.     theErr = NMInstall(&gTheNMRec);
  106.     PrimeTime(gOurTask, 10000);
  107.  
  108.  
  109.  
  110.     // Restore A4 for our caller
  111.     PatchUngetGlobals();
  112. }
  113.